﻿using System;
using System.Text;
using System.Collections.Generic;
using DDotNet.ORM.ORMapping.Enum;
using GenericTests.Entities;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace GenericTests
{
    /// <summary>
    /// Summary description for StrategyTest
    /// </summary>
    [TestClass]
    public class StrategyTest
    {
        public StrategyTest()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        [TestMethod]
        public void BusinessEqualTest_KeyComparison_True()
        {
            // Cria Objetos
            Customer customerI = new Customer();
            Customer customerII = new Customer();
            
            // Configura ID
            customerI.ID = 88;
            customerII.ID = 88;

            // Configura Nome
            customerI.Name = "ABC!@#";
            customerII.Name = "ABC!@#";
            
            // Utiliza o BusinessEquals
            Assert.IsTrue(customerI.Equals(customerII, BusinessEqualMode.KeyComparison), "Falha na Comparação");
        }

        [TestMethod]
        public void BusinessEqualTest_PropertiesComparison_True()
        {
            // Cria Objetos
            Customer customerI = new Customer();
            Customer customerII = new Customer();

            // Configura ID
            customerI.ID = 1;
            customerII.ID = 1;

            // Configura Nome
            customerI.Name = "XPTO(*&";
            customerII.Name = "XPTO(*&";

            // Utiliza o BusinessEquals
            Assert.IsTrue(customerI.Equals(customerII, BusinessEqualMode.PropertiesComparison), "Falha na Comparação");
        }

        [TestMethod]
        public void BusinessEqualTest_PropertiesComparison_False()
        {
            // Cria Objetos
            Customer customerI = new Customer();
            Customer customerII = new Customer();

            // Configura ID
            customerI.ID = 1;
            customerII.ID = 1;

            // Configura Nome
            customerI.Name = "XPTO(*&";
            customerII.Name = "fff";

            // Utiliza o BusinessEquals
            Assert.IsFalse(customerI.Equals(customerII, BusinessEqualMode.PropertiesComparison), "Falha na Comparação");
        }

        [TestMethod]
        public void BusinessEqualTest_KeyComparison_False()
        {
            // Cria Objetos
            Customer customerI = new Customer();
            Customer customerII = new Customer();

            // Configura ID
            customerI.ID = 89;
            customerII.ID = 88;

            // Configura Nome
            customerI.Name = "ABC!@#";
            customerII.Name = "ABC!@#";

            // Utiliza o BusinessEquals
            Assert.IsFalse(customerI.Equals(customerII, BusinessEqualMode.KeyComparison), "Falha na Comparação");
        }

        [TestMethod]
        public void CloneTest()
        {
            // Cria Objetos
            Customer customerI = new Customer();
            Customer customerII;

            // Configura ID
            customerI.ID = 88;

            // Configura Nome
            customerI.Name = "ABC!@#";
            
            // Clona Entidade
            customerII = (Customer) customerI.Clone();

            // Utiliza o BusinessEquals
            Assert.IsTrue(customerI.Equals(customerII, BusinessEqualMode.KeyComparison), "Falha na Clonagem");
        }
    }
}
